package tjx.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.Timer;

@WebServlet(name = "firstServlet"/*,urlPatterns = {"/FirstServlet","/timerServlet"},loadOnStartup = 1*/)
//@WebServlet(name = "tjx.struts")
public class FristServlet extends HttpServlet {
    public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,java.io.IOException
    {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charSet=UTF-8");
        String name=request.getParameter("name");
        String gender=request.getParameter("gender");
        String[] color=request.getParameterValues("color");
        String national=request.getParameter("national");
        PrintStream out=new PrintStream(response.getOutputStream());
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet测试</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("您的名字："+name+"<hr/>");
        out.println("您的性别："+gender+"<hr/>");
        out.println("您喜欢的颜色：");
        for(String c:color)
        {
            out.println(c+"");
        }
        out.println("<hr/>");
        out.println("您来自的国家："+national+"<hr/>");
        out.println("</body>");
        out.println("</html>");
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
